package cn.smile.controller.core;

import cn.smile.bean.form.core.file.FileUploadForm;
import cn.smile.business.core.IFileUploadService;
import cn.smile.commons.response.MyResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import jakarta.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 龙逸
 * @since 2022-04-01
 */
@RestController
@RequestMapping("api/file")
public class FileUploadController {

    @Resource
    private IFileUploadService service;

    @PostMapping("upload")
    public MyResult<String> fileUpload(FileUploadForm form) {
        return MyResult.OK(service.fileUpload(form));
    }

    @PostMapping("miniUpload")
    public String miniUpload(@RequestParam("file") MultipartFile file){
        return service.miniUpload(file);
    }
}
